home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Windows News 2010 Summer - Disc 1
/
WN_Ete2010_CD1.iso
/
Onglet5
/
Weezo
/
Weezo setup.exe
/
{code_appDir}
/
www
/
js
/
uiUsers-src.js
< prev
next >
Wrap
Text File
|
2010-05-19
|
8KB
|
234 lines
function init(){
winResized();
uiUserResetBlocks();
uiUserScrollTo();
}
function winResized(){
alignBottom(dgi('usersListFrame'),winMe)
alignBottom(dgi('userFrame'),winMe)
alignBottom(dgi('linkedResourcesFrame'),winMe,5)
}
function uiUserScrollTo(id){
if(!id) id=uiUserSelected;
dgi('uiUsersBlocksDiv').scrollTop=dgi('userBlock_'+id).offsetTop+dgi('userBlock_'+id).offsetHeight-dgi('uiUsersBlocksDiv').offsetHeight;
}
// Create user
function uiUserCreate(){
wl.UIWebPopup('/local/uiUsers/newUser.php',uiUserCreateCB)
}
function uiUserCreateCB(ud){
wl.asr.send({'userCreate':ud})
}
// Delete user
function uiUserDelete(id){
if(!confirm(delConfCapt.replace(/%1/,dgi('uiUsersDataName').value))) return;
wl.asr.send({'userDelete':id});
}
// Select user
function uiUserSelect(id){
if(uiUsersDataNameChangedTO) {
clearTimeout(uiUsersDataNameChangedTO); uiUsersDataNameChangedTO=0;
uiUsersDataNameChangedApply();
}
if(uiUsersDataHintChangedTO) {
clearTimeout(uiUsersDataHintChangedTO); uiUsersDataHintChangedTO=0;
uiUsersHintChangedApply();
}
if(id==uiUserSelected) return;
for(var i=0;i<users.length;i++){
if(dgi('del_'+users[i])) dgi('del_'+users[i]).style.display=((users[i]==id)?'':'none')
}
wl.asr.send({'userSelect':1,'userId':id})
uiUserSelected=id;
return true;
}
// Send mail invitation
function uiUserSendInvitation(id){wl.asr.send({'userSendInvitation':1,'userId':id})}
function uiUserResetBlocks(){
for(var i=0;i<users.length;i++) {
dgi('userBlock_'+users[i]).style.top=((i==0)?0:5+dgi('userBlock_'+users[i-1]).offsetTop+Math.max(70,dgi('userBlock_'+users[i-1]).offsetHeight))+'px';
dgi('up_'+users[i]).style.display=((i)?'':'none');
dgi('down_'+users[i]).style.display=((i!=users.length-1)?'':'none');
}
}
function uiUserBlockUp(id){
var pos=uiMiscPos(users,id);
uiUserSwap(users[pos-1],id);
wl.fadeStyle('userBlock_'+id,top)
}
function uiUserBlockDown(id){
var pos=uiMiscPos(users,id);
uiUserSwap(id,users[pos+1]);
}
function uiUserSwap(id1,id2){
var p1=dgi('userBlock_'+id2).offsetTop,p2=dgi('userBlock_'+id1).offsetTop;
var i1=uiMiscPos(users,id1),i2=uiMiscPos(users,id2);
users[i1]=id2;users[i2]=id1;
wl.fadeStyle('userBlock_'+id1,'top',p1,'linear',10)
wl.fadeStyle('userBlock_'+id2,'top',p2,'linear',10,'uiUserResetBlocks()');
wl.asr.send({'userOrder':users.toString()})
}
function uiMiscPos(arr,val){
for(var i=0;i<arr.length;i++) if(arr[i]==val) return i;
}
function uiUserActivated(id){
dgi('uiUsersActWarning').style.display=(dgi('activated_'+id).checked)?'none':'';
winResized();
uiUserUpdate('activated',dgi('activated_'+id).checked,id)
}
/**
* Send data for update
*/
function uiUserUpdate(dataName,dataValue,id){
wl.asr.send({'updateData':dataName,'updateValue':dataValue,'userId':((id)?id:uiUserSelected)})
}
// Name
var uiUsersDataNameChangedTO;
function uiUsersDataNameChanged(n){
dgi('uiUserBlockName'+uiUserSelected).innerHTML=n.value;
if(uiUsersDataNameChangedTO) clearTimeout(uiUsersDataNameChangedTO);
uiUsersDataNameChangedTO=W.setTimeout("uiUsersDataNameChangedApply()",1500)
}
function uiUsersDataNameChangedApply(){
uiUsersDataNameChangedTO=0;
uiUserUpdate('name',dgi('uiUsersDataName').value);
}
// Icon
function uiUserChangeIcon(){
wl.UIWebPopup('/local/userIcon.php?userId='+uiUserSelected,uiUserChangeIconCB)
}
function uiUserChangeIconCB(newIcon){
dgi("selUserIcon").src='/gfx/icons/'+newIcon;
dgi("uiUserBlockIcon"+uiUserSelected).src='/gfx/icons/'+newIcon;
uiUserUpdate('icon',newIcon);
}
// Authentication method
function uiUsersDataAuthenticationChanged(auth){
if(auth=='password') {
uiUsersPwdSet(1);
dgi('uiUsersDataHint').disabled=false;
}
else {
uiUserUpdate('authenticationMethod','noAuthentication');
dgi('uiUsersDataHint').disabled=true;
}
}
// Password
var uiUsersPwdSetFromSelect;
function uiUsersPwdSet(fromSelect){
if(fromSelect) dgn("passwordSelect").value="noAuthentication"
uiUsersPwdSetFromSelect=fromSelect;
wl.UIWebPopup('/local/uiUsers/password.php',uiUsersPwdSetCB)
}
function uiUsersPwdSetCB(res){
if(res!="") {
uiUserUpdate('password',res);
dgi('uiUsersDataHint').disabled=false;
}
dgi('uiUsersDataAuthenticationNA').selected=true;
}
// Hint
var uiUsersDataHintChangedTO;
function uiUsersDataHintChanged(n){
if(uiUsersDataHintChangedTO) clearTimeout(uiUsersDataHintChangedTO);
uiUsersDataHintChangedTO=setTimeout("uiUsersHintChangedApply()",1500)
}
function uiUsersHintChangedApply(){
uiUsersDataHintChangedTO=0;
uiUserUpdate('hint',dgi('uiUsersDataHint').value);
}
// Toggle advanced configuration
function uiUsersToggleAdvancedConfig(){
uiShowAdvancedConfig=1-uiShowAdvancedConfig;
if(uiShowAdvancedConfig){
dgi('advancedConfigDiv').style.display='';
dgi('advancedConfigFoldIco').style.display='none';
dgi('advancedConfigUnfoldIco').style.display='';
}
else{
dgi('advancedConfigDiv').style.display='none';
dgi('advancedConfigUnfoldIco').style.display='none';
dgi('advancedConfigFoldIco').style.display='';
}
winResized();
wl.asr.send({'userShowAdvancedConfig':uiShowAdvancedConfig})
}
// DL limit
function uiUsersDataDLLimitChanged(v){
if(isNaN(v.value) || v.value<0) v.style.color='red';
else{
v.style.color='';
uiUserUpdate('downloadSpeedLimit',v.value)
}
}
// IP filter
function uiUsersIPSet(){
wl.UIWebPopup('/local/IPFilter.php?userFile='+uiUserFile,uiUsersIPSetCB)
}
function uiUsersIPSetCB(res){
if(res!=0) btSetIcon('uiUsersIPBt','/gfx/warning.png'); else btSetIcon('uiUsersIPBt','/gfx/ahead.png');
}
// Select a theme
function uiUsersSelectTheme(){wl.UIWebPopup('/local/themeSelection.php?userFile='+uiUserFile,uiUsersSelectThemeCB)}
function uiUsersSelectThemeCB(res){uiUserUpdate('theme',res)}
// Add a resource
function uiUsersAddResource(){wl.UIWebPopup('/local/uiUsers/bindResourceToUser.php?selectedUserId='+uiUserSelected,uiUsersAddResourceCB)}
function uiUsersAddResourceCB(r){
// User requested a new resource creation
if(r=='createNewResource') wl.asr.send({'userId':uiUserSelected,'userCreateNewResource':r});
// Else user's resources modified
else wl.asr.send({'userId':uiUserSelected,'userAddResources':r})
}
// Remove a resource
function uiUsersResDel(rid){fade('uiUsersResBlock_'+rid,1,0,10,'uiUsersResDelCB("'+rid+'")')}
function uiUsersResDelCB(rid){wl.asr.send({'removeResource':rid,'userId':uiUserSelected})}
// Change resources order
function uiUsersResUp(rid){
var n=dgi('uiUsersResBlock_'+rid),p=n.previousSibling;
uiUsersResSwap(p,n);
}
function uiUsersResDown(rid){
var n=dgi('uiUsersResBlock_'+rid),p=n.nextSibling;
uiUsersResSwap(n,p);
}
// Swap order of 2 resources
function uiUsersResSwap(n,p){
var ln=actualOffsetLeft(n),tn=actualOffsetTop(n);
var lp=actualOffsetLeft(p),tp=actualOffsetTop(p);
wl.fadeStyle(n.id,'top',tp-tn,'linear',10);
wl.fadeStyle(n.id,'left',lp-ln,'linear',10);
wl.fadeStyle(p.id,'top',tn-tp,'linear',10);
wl.fadeStyle(p.id,'left',ln-lp,'linear',10,'uiUsersResSwapCB(\''+n.id+'\',\''+p.id+'\')');
}
function uiUsersResSwapCB(nid,pid){
nid=nid.substr(nid.indexOf('_')+1)
pid=pid.substr(pid.indexOf('_')+1)
wl.asr.send({'userResMoveUp':nid,'userResMoveDown':pid,'userId':uiUserSelected})
}
// Change resource displayed at user's login
function uiUsersResLogin(rid){
if(!rid) rid='';
uiUserUpdate('displayResourceAtLogin',rid);
}
// Set resource frame scroll position at initial position after an async update
var uiUsersResScroll=0;
function uiUsersResScrollGet(){
uiUsersResScroll=dgi('linkedResourcesScroll').scrollTop;
}
function uiUsersResScrollSet(){
dgi('linkedResourcesScroll').scrollTop=uiUsersResScroll;
}
init();